package com.polonium.eclipserunner.webdriver.example;

import com.polonium.eclipserunner.core.annotations.DetailedDescription;
import com.polonium.eclipserunner.core.annotations.Given;
import com.polonium.eclipserunner.core.annotations.Then;
import com.polonium.eclipserunner.core.annotations.When;
import com.polonium.eclipserunner.webdriver.PoloniumWebdriver;
import com.polonium.eclipserunner.webdriver.annotations.TargetBrowser;
import com.polonium.eclipserunner.webdriver.example.pages.OnetMainPage;
import com.polonium.eclipserunner.webdriver.example.pages.SearchResultsPage;
import org.junit.Test;

import static com.polonium.eclipserunner.webdriver.Browser.FIREFOX;
import static com.polonium.eclipserunner.webdriver.Browser.IEXPLORER;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

@DetailedDescription
@TargetBrowser({ FIREFOX, IEXPLORER })
public class OnetSearchTest extends PoloniumWebdriver{
	
	@Given("main onet.pl page")
	@When("enter phase and click search")
	@Then("at least result is displayed")
	@Test
	public void shouldDisplaySomeResults(){
		OnetMainPage onetMainPage = new OnetMainPage();
		
		SearchResultsPage searchResultsPage = onetMainPage
				.fillSearchField()
				.clickSearchButton();
		
		assertTrue(searchResultsPage.isAnyResultDisplayed());
	}
	
	@Given("main onet.pl page")
	@When("click search without entering phase")
	@Then("no results are displayed")
	@Test
	public void shouldNotDisplayAnyResult(){
		OnetMainPage onetMainPage = new OnetMainPage();
		
		SearchResultsPage searchResultsPage = onetMainPage
				.clickSearchButton();
		
		assertFalse(searchResultsPage.isAnyResultDisplayed());
	}
}
